import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.util.CellRangeAddress;


public class Test {

	public static void main(String[] args) {

		HSSFWorkbook wb = new HSSFWorkbook();
		HSSFSheet sheet = wb.createSheet("哈哈哈");
		
		for(int i = 0; i < 5; i++){
			
			HSSFRow row = sheet.createRow(i);
			for(int j = 0; j < 10; j++){
				
				HSSFCell cell = row.createCell(j);
				cell.setCellValue(i + "--" + j);
			}
		}
		
		CellRangeAddress region = new CellRangeAddress(0, 1, 2, 3);
		sheet.addMergedRegion(region);
		
		FileOutputStream out = null;
		try {
			File file = new File("/Users/tuyou/1.xls");
			if(!file.exists()){
				
				file.createNewFile();
			}
			out = new FileOutputStream(file);
			wb.write(out);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			
			if(out != null){
				
				try {
					out.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
